﻿using Itech_Run.Helper.Configure;
using Itech_Run.Sys.Domain.Entity;
using Itech_Run.Sys.EntityFrameworkCore.SeedData;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System.Diagnostics;
using Volo.Abp.EntityFrameworkCore;

namespace Itech_Run.Sys.EntityFrameworkCore
{
    [Volo.Abp.Data.ConnectionStringName("Itech_RunConnectionStr")]
    public partial class Itech_RunSysContext : AbpDbContext<Itech_RunSysContext>
    {
        public readonly IOptions<AesOptions> _aesOptions;
        public Itech_RunSysContext(DbContextOptions<Itech_RunSysContext> options, IOptions<AesOptions> aesOptions) : base(options)
        {
            _aesOptions = aesOptions;
        }

        public virtual DbSet<Sys_Button> Sys_Button { get; set; }
        public virtual DbSet<Sys_Dictionary> Sys_Dictionary { get; set; }
        public virtual DbSet<Sys_Job> Sys_Job { get; set; }
        public virtual DbSet<Sys_Module> Sys_Module { get; set; }
        public virtual DbSet<Sys_ModuleButton> Sys_ModuleButton { get; set; }
        public virtual DbSet<Sys_ProcedureException> Sys_ProcedureException { get; set; }
        public virtual DbSet<Sys_Role> Sys_Role { get; set; }
        public virtual DbSet<Sys_RoleModule> Sys_RoleModule { get; set; }
        public virtual DbSet<Sys_RoleModuleButton> Sys_RoleModuleButton { get; set; }
        public virtual DbSet<Sys_TokenGrey> Sys_TokenGrey { get; set; }
        public virtual DbSet<Sys_User> Sys_User { get; set; }
        public virtual DbSet<Sys_UserRole> Sys_UserRole { get; set; }
        public virtual DbSet<Sys_User_RefreshToken> Sys_User_RefreshToken { get; set; }
        public virtual DbSet<Sys_Resume> Sys_Resume { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            optionsBuilder.LogTo(message => Debug.WriteLine(message), LogLevel.Debug); //出现在“输出 - 调试”窗口
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //Seed Data
            modelBuilder.CommonSeed(_aesOptions);

            base.OnModelCreating(modelBuilder);
        }
    }
}
